<template>
	<body>
			<section>
				<div class="wrapper">
					<div class="userform">
						<div class="loginform">
							<h2><span>登录</span><router-link to="/register">丨注册</router-link></h2>
							<form class="form-logo" action="" :model="form" method="post">
								<p><input type="text" class="username" v-model="form.username" id="txtinfor" placeholder="请输入用户名" /></p>
								<p><input type="password" class="psd" id="txtinfor" v-model="form.password" placeholder="请输入密码" /></p>
								<p><input type="checkbox" class="ckbox"  value="" checked="checked" />记住我（请在私人设备上使用该功能）</p>
								<p>还没账号，先<a href="UltramanJack.html"><span id="red">注册</span></a><el-button type="danger" class="loginbt" @click="login()"  style="cursor: pointer">登录</el-button></p>
							</form>
						</div>
					</div>
				</div>
			</section>
			<footersa></footersa>
		</body>
</template>

<script>
  import request from "@/utils/request.js";
  import {ElMessage} from "element-plus";
  import router from "@/router/index.js";
  // import header from "@/components/header.vue";
  export default {
    data(){
      return{
        form: {}
      }
    },
    methods: {
      login(){
        request.post("/api/userLogin",this.form).then(
            res => {
              // console.log("res",res)
              // console.log(res.code)
              if (res.code === "200"){
                ElMessage({
                  message: '登录成功',
                  type: 'success',
                })
                // location.reload();
                router.push("/index");
                // this.$refs.header.member();
              }else if (res.code === "555"){
                ElMessage({
                  message: '账号或密码错误',
                  type: 'error',
                })
              }
            }
        )
      }
    }
  }
</script>

<style>
</style>